﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace AndreySmirnov.BLToolkitUtils.VSPackage.UI
{
	public class BoolToVisibilityConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is bool && targetType == typeof(Visibility))
			{
				return ((bool) value) ? Visibility.Visible : Visibility.Collapsed;
			}
			return DependencyProperty.UnsetValue;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is Visibility && targetType == typeof(bool))
			{
				return ((Visibility) value) == Visibility.Visible ? true : false;
			}
			return DependencyProperty.UnsetValue;
		}
	}
}
